package com.gupao.study.proxy.jdkProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class HouseProxy{
	private Class target = null;
	public HouseProxy(Class p) {
		target = p;
	}

	public Object getInstance() {
		return Proxy.newProxyInstance(target.getClassLoader(), 
				                      target.getInterfaces(), 
				                      new InvocationHandler() {
										
										@Override
										public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
											// TODO Auto-generated method stub
											System.out.println("房屋中介：帮忙找房子");
											method.invoke(target.newInstance(), args);
											System.out.println("找到了140的毛坯房;");
											return null;
										}
									});
	}
}
